
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class FmsMaterialCategoryServiceImpl implements FmsMaterialCategoryService  {

    @Resource
    private FmsMaterialCategoryMapper fmsMaterialCategoryMapper;

    /**
     * 获取 FmsMaterialCategory 分页列表
     */
    @Transactional
    public IPage getFmsMaterialCategoryPagination( PaginationVo paginationVo, FmsMaterialCategoryQuery fmsMaterialCategoryQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<FmsMaterialCategoryEntity> lqs = new LambdaQueryWrapper();
        fmsMaterialCategoryMapper.selectPage(page, lqs);

        List<FmsMaterialCategoryEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 FmsMaterialCategory 所有数据
     *
    */
    @Transactional
    public List<FmsMaterialCategoryEntity> getFmsMaterialCategoryAllList( FmsMaterialCategoryQuery fmsMaterialCategoryQuery ) throws Exception {

        LambdaQueryWrapper<FmsMaterialCategoryEntity> lqs = new LambdaQueryWrapper();
        List<FmsMaterialCategoryEntity> list = fmsMaterialCategoryMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 FmsMaterialCategory 详情
    */
    @Transactional
    public FmsMaterialCategoryEntity getFmsMaterialCategoryDetail( Long id) throws Exception {

        FmsMaterialCategoryEntity fmsMaterialCategory = fmsMaterialCategoryMapper.selectById(id);
        return fmsMaterialCategory;
    }


    /**
     * 新增 FmsMaterialCategory
     * */
    @Transactional
    public void addFmsMaterialCategory(FmsMaterialCategoryVo fmsMaterialCategoryVo) throws Exception {

        FmsMaterialCategoryEntity fmsMaterialCategory = new FmsMaterialCategoryEntity();
        ReflectionCopy.copyProperties( fmsMaterialCategory, fmsMaterialCategoryVo );
        fmsMaterialCategoryMapper.insert(fmsMaterialCategory);
        return;
    }


    /**
     * 更新 FmsMaterialCategory
     * */
    @Transactional
    public void updateFmsMaterialCategory( FmsMaterialCategoryVo fmsMaterialCategoryVo) throws Exception {

        if( fmsMaterialCategoryVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        FmsMaterialCategoryEntity fmsMaterialCategory = new FmsMaterialCategoryEntity();
        ReflectionCopy.copyProperties( fmsMaterialCategory, fmsMaterialCategoryVo );
        fmsMaterialCategoryMapper.updateById(fmsMaterialCategory);
        return;
    }

    /**
     * 删除 FmsMaterialCategory
     * */
    @Transactional
    public void batchRemoveFmsMaterialCategory( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        fmsMaterialCategoryMapper.deleteBatchIds(ids);
    }

}

      